/*     */ package com.wzh.service.siteinfo;
/*     */ 
/*     */ import com.wzh.bean.collect.SiteInfo;
/*     */ import com.wzh.constant.CollectConstant;
/*     */ import com.wzh.service.base.DaoSupport;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.persistence.EntityManager;
/*     */ import javax.persistence.Query;
/*     */ import org.springframework.stereotype.Service;
/*     */ import org.springframework.transaction.annotation.Propagation;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ 
/*     */ @Service
/*     */ @Transactional
/*     */ public class SiteInfoServiceBean extends DaoSupport<SiteInfo>
/*     */   implements SiteInfoService
/*     */ {
/*     */   @Transactional(readOnly=true, propagation=Propagation.NOT_SUPPORTED)
/*     */   public boolean findByDomain(String domain)
/*     */   {
/*  24 */     Query query = this.em.createQuery("select count(o) from SiteInfo o where o.domain=?1");
/*  25 */     query.setParameter(1, domain);
/*  26 */     long count = ((Long)query.getSingleResult()).longValue();
/*  27 */     return count > 0L;
/*     */   }
/*     */ 
/*     */   public void replaceContent(SiteInfo info)
/*     */   {
/*  32 */     if (info != null) {
/*  33 */       String titleReg = info.getTitleReg();
/*  34 */       String imageurl = info.getImgurlReg();
/*  35 */       String author = info.getAuthorReg();
/*  36 */       String intro = info.getIntroReg();
/*  37 */       String chapter = info.getChaptertitleAndUrlReg();
/*  38 */       String chapterContent = info.getChapterContentReg();
/*  39 */       String booktype = info.getBooktypeReg();
/*  40 */       String bookstate = info.getStateReg();
/*  41 */       String updatetime = info.getUpdatetimeReg();
/*  42 */       String contentUrlReg = info.getContentUrlReg();
/*     */ 
/*  45 */       if (contentUrlReg != null) {
/*  46 */         contentUrlReg = contentUrlReg.replace("[!contenturl]", CollectConstant.URLREGSTR);
/*     */       }
/*     */ 
/*  49 */       if (booktype != null) {
/*  50 */         booktype = booktype.replace("[!booktype]", CollectConstant.TITLEREGSTR);
/*     */       }
/*  52 */       if (bookstate != null) {
/*  53 */         bookstate = bookstate.replace("[!bookstate]", CollectConstant.TITLEREGSTR);
/*     */       }
/*  55 */       if (updatetime != null) {
/*  56 */         updatetime = updatetime.replace("[!updatetime]", CollectConstant.TITLEREGSTR);
/*     */       }
/*  58 */       if (titleReg != null) {
/*  59 */         titleReg = titleReg.replace("[!title]", CollectConstant.TITLEREGSTR);
/*     */       }
/*  61 */       if (imageurl != null) {
/*  62 */         imageurl = imageurl.replace("[!imageurl]", CollectConstant.URLREGSTR);
/*     */       }
/*  64 */       if (author != null) {
/*  65 */         author = author.replace("[!author]", CollectConstant.TITLEREGSTR);
/*     */       }
/*  67 */       if (intro != null) {
/*  68 */         intro = intro.replace("[!intro]", CollectConstant.CONTENTREGSTR);
/*     */       }
/*  70 */       if (chapter != null) {
/*  71 */         chapter = chapter.replace("[!chapterurl]", CollectConstant.URLREGSTR);
/*  72 */         chapter = chapter.replace("[!chaptertitle]", CollectConstant.TITLEREGSTR);
/*     */       }
/*  74 */       if (chapterContent != null) {
/*  75 */         chapterContent = chapterContent.replace("[!chapterContent]", CollectConstant.CONTENTREGSTR);
/*     */       }
/*     */ 
/*  78 */       info.setBooktypeReg(booktype);
/*  79 */       info.setStateReg(bookstate);
/*  80 */       info.setUpdatetimeReg(updatetime);
/*  81 */       info.setTitleReg(titleReg);
/*  82 */       info.setImgurlReg(imageurl);
/*  83 */       info.setAuthorReg(author);
/*  84 */       info.setIntroReg(intro);
/*  85 */       info.setChaptertitleAndUrlReg(chapter);
/*  86 */       info.setChapterContentReg(chapterContent);
/*  87 */       info.setContentUrlReg(contentUrlReg);
/*     */     }
/*     */   }
/*     */ 
/*     */   public String[] getListUrls(SiteInfo info)
/*     */   {
/*  93 */     if (info != null) {
/*  94 */       String listurl = info.getListUrl();
/*  95 */       if (listurl != null) {
/*  96 */         return listurl.split("[\n\r]+");
/*     */       }
/*     */     }
/*  99 */     return null;
/*     */   }
/*     */ 
/*     */   public String[] getListOldStr(SiteInfo info)
/*     */   {
/* 105 */     if (info != null) {
/* 106 */       String oldcontent = info.getOldcontent();
/* 107 */       if (oldcontent != null) {
/* 108 */         return oldcontent.split("[\n\r]+");
/*     */       }
/*     */     }
/* 111 */     return null;
/*     */   }
/*     */ 
/*     */   public String[] getListNewStr(SiteInfo info)
/*     */   {
/* 116 */     if (info != null) {
/* 117 */       String newcontent = info.getNewcontent();
/* 118 */       if (newcontent != null) {
/* 119 */         return newcontent.split("[\n\r]+");
/*     */       }
/*     */     }
/* 122 */     return null;
/*     */   }
/*     */ 
/*     */   public Map<String, String> getRegMap(SiteInfo info)
/*     */   {
/* 127 */     if (info == null) {
/* 128 */       return null;
/*     */     }
/*     */ 
/* 131 */     Map map = new HashMap();
/* 132 */     map.put(CollectConstant.TITLE, info.getTitleReg());
/* 133 */     map.put(CollectConstant.IMAGEURL, info.getImgurlReg());
/* 134 */     map.put(CollectConstant.AUTHOR, info.getAuthorReg());
/* 135 */     map.put(CollectConstant.INTRO, info.getIntroReg());
/* 136 */     map.put(CollectConstant.BOOKTYPE, info.getBooktypeReg());
/* 137 */     map.put(CollectConstant.BOOKSTATE, info.getStateReg());
/* 138 */     map.put(CollectConstant.UPDATETIME, info.getUpdatetimeReg());
/*     */ 
/* 140 */     return map;
/*     */   }
/*     */ }

/* Location:           C:\work\apache-tomcat-7.0.55\webapps\ROOT\WEB-INF\classes\
 * Qualified Name:     com.wzh.service.siteinfo.SiteInfoServiceBean
 * JD-Core Version:    0.6.1
 */